import './index.css';
// import './util/jquery.atwho_wev8.css';
// require('./util/jquery.nicescroll_wev8.js');
// require('./util/jquery.atwho_wev8.js');
// require('./util/jquery.caret_wev8.js');

import { WeaRichText, WeaLocaleProvider, WeaHelpfulTip, WeaTools } from 'ecCom';
import { WeaAutograph } from 'comsMobx';
const WeaAutographComp = WeaAutograph.Component;
import trim from 'lodash/trim';
import FileUpload from './plugin/upload/index';
import WfAt from './plugin/wfat/index';
import WfPhrase from './plugin/wfphrase/index';
import Wfsignature from './plugin/signature/index';
import WfMapLocation from './plugin/wfMapLocation/index';
import { Icon, message, Button } from 'antd';
import * as SignUtil from '../../util/signUtil';
import objectAssign from 'object-assign';
import { saveMobileSignAnnex } from './../../apis/api'
import { getLocationInfoData  } from '../../util/signUtil'
const getLabel = WeaLocaleProvider.getLabel;

export default class Main extends React.Component {
    constructor(props) {
        super(props);
        const { remark = '', workflowRequestLogId="-1", markInfo = {}, signdocids = '', signdocreplacedata = [], signworkflowids = '', signworkflowreplacedata = [], annexdocids = '', annexdocinfos = [], remarkLocation = '' 
    ,belongTest} = props;
        const { extendParams = {}, remarkInfo = {} } = markInfo;
        const { signinputPhraseDirection, signinputPhraseWidth } = extendParams;
        const { signHandWritten = {},signHandWrittenColor="#010102", signHandWrittenBrush="md"} = remarkInfo;
        const intiData = {
            remark: remark,
            visibleComponent: '',
            hasInitListUploadComponent: false,
            signdocids: signdocids,
            signdocreplacedata: signdocreplacedata,
            workflowRequestLogId:workflowRequestLogId,
            signHandWrittenColor:signHandWrittenColor,
            signHandWrittenBrush:signHandWrittenBrush,
            signHandWritten: signHandWritten,
            signhandwrittenid: signHandWritten.fileid,
            signworkflowids: signworkflowids,
            signworkflowreplacedata: signworkflowreplacedata,
            annexdocids: annexdocids,
            annexdocinfos: annexdocinfos,
            remarkLocation: remarkLocation,
            remarkLocationInfo: remarkLocation || {},
            autographStore: new WeaAutograph.AutographStore(),
            signinputPhraseDirection: signinputPhraseDirection,
            signinputPhraseOffset: -34,
            triangleLeft: signinputPhraseWidth / 2,
            operators: [],
            signatureVisiable: false,
            belongTest:belongTest,
        };
        const { editorId, visible = false } = props;
        this.state = this.initForwardRemarkData(editorId, visible, intiData);
        const { changeRemarkInfo } = props;
        changeRemarkInfo && changeRemarkInfo({ annexdocids: this.state.annexdocids, signdocids: this.state.signdocids, annexdocinfos: this.state.annexdocinfos, handWrittenSign: this.state.signhandwrittenid });
        if (!window.CK_REF) {
            window.CK_REF = {};
        }
    }

    componentWillReceiveProps(nextProps) {
        //转发
        const { editorId, visible = false, isClear = false, initRemarkContent = false, markInfo } = nextProps;
        if (initRemarkContent || editorId === "updateEdit") {
            this.setState(this.initForwardRemarkData(editorId, visible));
        }

        if (isClear && !this.props.isClear) {
            this.setState({
                remark: '',
                signdocids: '',
                signHandWritten: {},
                signhandwrittenid: "",
                signdocreplacedata: [],
                signworkflowids: '',
                signworkflowreplacedata: [],
                annexdocids: '',
                annexdocinfos: [],
                remarkLocation: ''
            });
        }

        if (editorId === "remark" && !isClear &&
            window.CK_REF && window.CK_REF.remark &&
            window.CK_REF.remark.props &&
            window.CK_REF.remark.props.isfwclear &&
            window.CK_REF.remark.props.isfwclear === "1") {//主要依赖‘isfwclear’参数在 updateWeaRichText方法中设置
            // this.setState({remark:window.CK_REF.remark.props.value});
            this.setState({ "remark": `<p>${window.CK_REF.remark.props.value}</p>` }, () => {
                const el = this.refs.WeaRichText.getEditor().document.$;
                const _this = this;
                $(el).off("click").on("click", function (e) {
                    _this.setState({ visibleComponent: '' });
                });
            });//注意这里一定需要这个p标签
        }
    }

    shouldComponentUpdate(nextProps, nextState) {
        return this.state.remark !== nextState.remark ||
            this.state.signdocids !== nextState.signdocids ||
            this.state.signworkflowids !== nextState.signworkflowids ||
            this.state.annexdocinfos !== nextState.annexdocinfos ||
            this.state.remarkLocation !== nextState.remarkLocation ||
            this.state.visibleComponent !== nextState.visibleComponent ||
            this.state.signHandWritten !== nextState.signHandWritten ||
            this.state.signhandwrittenid !== nextState.signhandwrittenid ||
            this.state.hasInitListUploadComponent !== nextState.hasInitListUploadComponent ||
            this.state.signatureVisiable !== nextState.signatureVisiable ||
            this.props.isShowSignInput !== nextProps.isShowSignInput ||
            this.props.visible !== nextProps.visible ||
            this.props.reRender !== nextProps.reRender;
    }

    componentDidUpdate() {
        const { markInfo, visible = false, isEditorFocus = false, controlVariableMap, isShowSignInput } = this.props;
        const { use_textarea_signinput } = markInfo;
        if (!this.judgeIsSignature() && this.refs.WeaRichText) {
            const ckEditor = this.refs.WeaRichText.getEditor();
            if (isEditorFocus && ckEditor) {
                ckEditor.focus("last");
                typeof controlVariableMap === 'function' && controlVariableMap('isEditorFocus', false);
            }
        }
        if (isShowSignInput) {
            this.setWfPhraseExtendParams();
        }
    }

    componentDidMount() {
        const { markInfo, editorId } = this.props;
        const { isannexupload_edit = '', annexsecId = '' } = markInfo;
        if (isannexupload_edit === '1') {
            //未设置附件上传目录
            if (trim(annexsecId).length === 0 || annexsecId <= 0) {
                message.warning(getLabel('386190', "请设置签字意见附件上传目录"), 5);
            }
        }
    }

    judgeIsSignature = () =>  {
        const { markInfo } = this.props;
        return markInfo.isFormSignature == 1;
    }

    render() {
        if (this.judgeIsSignature())
            return this.renderSignature();      //手写签章
        else
            return this.renderRichText();   //富文本编辑器
    }

    renderRichText = () =>  {


        const { languageidweaver } = window.localStorage;
        const ckHeight = languageidweaver == 8 ? 125 : 150;//英文
        const { isShowSignInput = false, editorId, ls = false, ckConfig = {}, extentsConfig = [], bottomBarConfig = [], maxHeight = 0, markInfo = {} } = this.props;
        let { remark = '', signatureVisiable, belongTest } = this.state;

        window.remark6=remark;
        
        const { extendParams = {}, use_textarea_signinput,isannexupload_edit, remarkInfo = {} } = markInfo;
        const { handWrittenSignSwitch } = remarkInfo
        const { wfSignDefaultFontFamily = '', wfSignDefaultFontSize = '' } = extendParams; 
        let bottomBarRight = {};
        //初始化底部按钮
        this.initButtomConfig(bottomBarConfig);
        this.initExtentsConfig(extentsConfig);
        //基础配置
        ckConfig.toolbar = [
            //							[
            //							 'Source','-','Bold', 'Italic', 'Underline', 'Strike', '-',
            //							 'Font', 'FontSize',
            //							 'TextColor','BGColor','-',
            //							 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent','-','JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock','-',
            //							 'Link', 'Unlink','-',
            //							 'Table', '-', 'Undo', 'Redo','-',
            //							 'Maximize'
            //							]];

            { name: 'document', items: ['Source'] },
            { name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike',] },
            { name: 'styles', items: ['Font', 'FontSize'] },
            { name: 'colors', items: ['TextColor', 'BGColor'] },
            { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'] },
            { name: 'links', items: ['Link', 'Unlink'] },
            { name: 'tools', items: ['Maximize'] },
            { name: 'insert', items: ['Table', '-', 'Undo', 'Redo', 'Image'] }
        ];

        //		ckConfig.toolbar =  [
        //					            { name: 'markdown', items: [ 'Markdown' ] },
        //					            { name: 'document', items: [ 'Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates' ] },
        //					            { name: 'clipboard', items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
        //					            { name: 'editing', items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] },
        //					            { name: 'forms', items: [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
        //					            '/',
        //					            { name: 'basicstyles', items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'CopyFormatting', 'RemoveFormat' ] },
        //					            { name: 'paragraph', items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language' ] },
        //					            { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
        //					            { name: 'insert', items: [ 'Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe' ] },
        //					            '/',
        //					            { name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
        //					            { name: 'colors', items: [ 'TextColor', 'BGColor' ] },
        //					            { name: 'tools', items: [ 'Maximize', 'ShowBlocks' ] }
        //					        ];	

        if (editorId === "remark") {
            ckConfig.extraPlugins = 'autogrow';
        }
        ckConfig.height = ckHeight;
        ckConfig['autoGrow_minHeight'] = ckHeight;
        if (maxHeight > 0) ckConfig['autoGrow_maxHeight'] = maxHeight;
        if (editorId == "freeWorkflowSimple") ckConfig['autoGrow_maxHeight'] = 150;
        ckConfig.removePlugins = 'resize';
        ckConfig.uploadUrl = '/api/doc/upload/uploadFile';
        //		ckConfig.fontSize_defaultLabel = '12';
        //		ckConfig.fontSize_defaultSize = '12/12px';
        //		ckConfig.font_names = '仿宋_GB2312/FangSong_GB2312;宋体/SimSun;微软雅黑/Microsoft YaHei;楷体/KaiTi;黑体/SimHei;Arial/Arial, Helvetica, sans-serif;新宋体/NSimSun;楷体_GB2312/KaiTi_GB2312;';
        //		ckConfig.font_defaultLabel = '微软雅黑';
        //		ckConfig.font_defaultFamily = "微软雅黑/Microsoft YaHei";
        ckConfig.fontSize_sizes = '8/8px;9/9px;10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26/26px;28/28px;36/36px;48/48px;72/72px';
        ckConfig.startupFocus = false;
        let textareaStyle = {};
        let textareaRow = 10;
        if (wfSignDefaultFontFamily) {
            ckConfig.font_defaultFamily = wfSignDefaultFontFamily;
            if (use_textarea_signinput == 1 && wfSignDefaultFontFamily.indexOf('/') > -1) {
                textareaStyle['fontFamily'] = wfSignDefaultFontFamily.split('/')[1];
            }
        }
        if (wfSignDefaultFontSize) {
            ckConfig.fontSize_defaultSize = wfSignDefaultFontSize;
            if (use_textarea_signinput == 1 && wfSignDefaultFontSize.indexOf('/') > -1) {
                let fontSize = parseInt(wfSignDefaultFontSize.split('/')[0]);
                textareaStyle['fontSize'] = fontSize;
                textareaRow = parseInt(ckHeight / fontSize);
            }
        }
        const { annexmainId, annexsubId, annexsecId } = markInfo;
        const category = `${annexmainId},${annexsubId},${annexsecId}`;
        const ckprops = {
            id: editorId,
            ref: editorId,
            ls: ls,
            ckConfig: ckConfig,
            value: remark,
            scrollContainer: '.wea-new-top-req-content',
            dropToUploadFile:true,
            dropUploadFileUrl:`/api/doc/upload/uploadFile2Doc?category=${category}`,
            dropUploadFileParams:{
                isFirstUploadFile:9
            },
            dropToUploadImg:true,
            dropUploadImgUrl:"/api/doc/upload/uploadFile",
        };

        //未设置附件上传目录
        if (trim(annexsecId).length === 0 || annexsecId <= 0|| !isannexupload_edit) {
            ckprops.dropToUploadFile=false;
            ckprops.dropUploadFileUrl="";
        }
        if(belongTest){
            ckprops.layout = this.props.layout
        }
        return (
            <div style={{ "display": isShowSignInput ? "block" : "none" }} id={editorId} className='remark_div_ck'>
                {use_textarea_signinput == 1 ? <div className={handWrittenSignSwitch == 1 ? "wf-weaRichText-Textarea wf-hasBottomBarRight" : "wf-weaRichText-Textarea"}><WeaRichText.Textarea ecId={`${this && this.props && this.props.ecId || ''}_undefined@k5k1md`}
                    viewAttr={"2"}
                    value={remark}
                    onChange={this.doOnChangeEvent}
                    bottomBarConfig={bottomBarConfig}
                    onToolsChange={this.buttonBtnChange}
                    onKeyDown={this.onKeyDown}
                    maxRows={textareaRow}//高度控制
                    minRows={textareaRow}
                    textareaStyle={textareaStyle}
                    ref={'WeaRichText'}
                    onStatusChange={this.doStatusChange}
                /> </div> : <div className={handWrittenSignSwitch == 1 ? "wf-weaRichText-ck wf-hasBottomBarRight" : "wf-weaRichText-ck"}><WeaRichText ecId={`${this && this.props && this.props.ecId || ''}_WeaRichText@ch9swv`} {...ckprops}
                    bottomBarConfig={bottomBarConfig}
                    extentsConfig={extentsConfig}
                    onBlur={this.doOnChangeEvent}
                    onStatusChange={this.doStatusChange}
                    onToolsChange={this.buttonBtnChange}
                    ref={'WeaRichText'}
                /></div>}
                {signatureVisiable && this.getHandWrittenDom()}
            </div>
        )
    }

    getHandWrittenDom = () => {
        const { signHandWritten = {}, signatureVisiable, signHandWrittenColor ,signHandWrittenBrush} = this.state;
        return (
            <Wfsignature ecId={`${this && this.props && this.props.ecId || ''}_Wfsignature@yl51tl`}
                visiable={signatureVisiable}
                datas={signHandWritten}
                signHandWrittenColor={signHandWrittenColor}
                signHandWrittenBrush={signHandWrittenBrush}
                changeVisiable={this.changeSignatureVisiable}
                onOk={this.onSignatureOk}
            />
        )
    }

    onSignatureOk = (res, brush, color) => {
        this.changeSignatureVisiable(false);
        let submitDatas = {
            handWrittenSign: ""
        }
        if (res.isEmpty) {
            this.setState({ signHandWritten: { ...res, brush, color }, signhandwrittenid: "" })
            this.props.changeRemarkInfo && this.props.changeRemarkInfo(submitDatas)
        } else {
            res.modeType = res.mode;
            res.color=color;
            res.brush=brush;
            res.singleTrimUrls ? "" : res.singleTrimUrls = res.trimUrls;
            saveMobileSignAnnex({ type: 3, data: JSON.stringify(res) }).then((data = {}) => {
                const { fileid = [] } = data;
                res.fileid = fileid
                this.setState({ signHandWritten: { ...res, brush, color }, signhandwrittenid: fileid })//已保存的含fileid的数据
                submitDatas.handWrittenSign = fileid;
                submitDatas =  { ...submitDatas,signHandWritten: { ...res, brush, color }, signhandwrittenid: fileid };
                this.props.changeRemarkInfo && this.props.changeRemarkInfo(submitDatas)

            })
        }
    }


    changeSignatureVisiable = (val) => {
        this.setState({ signatureVisiable: val })
    }

    onKeyDown = (e) => {
        e.stopPropagation();
    }

    renderSignature = () =>  {
        const { isShowSignInput = false, editorId, markInfo = {}, bottomBarConfig = [] } = this.props;
        const { autographStore,workflowRequestLogId, signatureVisiable } = this.state;
        autographStore.setMobxState({ recordId: workflowRequestLogId });
        this.initButtomConfig(bottomBarConfig);
        const graphParams = { requestid: markInfo.requestid, workflowid: markInfo.workflowid, nodeid: markInfo.nodeid };
        return (
            <div  tabindex="50" onBlur={this.autographOnBlur} style={{ "display": isShowSignInput ? "block" : "none" ,outline:"0", hidefocus:"true"}} id={editorId} className='remark_div_Signature'>
                <WeaAutographComp ecId={`${this && this.props && this.props.ecId || ''}_WeaAutographComp@6n7zys`}
                    recordId={workflowRequestLogId}
                    // recordId={markInfo.workflowRequestLogId}
                    params={graphParams}
                    weaworkflow_autograph_store={autographStore}
                    bottomBarConfig={bottomBarConfig}
                    onStatusChange={this.triggerLoadReady}
                    onToolsChange={this.buttonBtnChange}
                    ref={res=>window["wfWeaAutographComp"+editorId]=res}
                    indexOfAutograph={"wfWeaAutographComp"+editorId}
                />
                 {signatureVisiable && this.getHandWrittenDom()}
            </div>
        )
    }

    autographOnBlur=(e)=>{
        this.props.onAutographBlur&&this.props.onAutographBlur();
    }
    doOnChangeEvent = (value) =>  {
        const {  markInfo = {} } = this.props;
        const { use_textarea_signinput } = markInfo;
        if(use_textarea_signinput == 1)
            this.setState({ remark: value });
		if(window.WfForm) {
            wfform.getLayoutStore().existChangeFormData=true;
        }
        this.props.onChange && this.props.onChange({ remark: value }, true);
    }

    buttonBtnChange = (name = '', ids = '', list = [], type = '', addfileid = '',isDel)  => {
        let returnInfo = [];
        let changedatas = {};
        let submitDatas = {};
        const { requestid = -1, markInfo = {} } = this.props;
        const { annexdocinfos=[] } = this.state;
        const { use_textarea_signinput } = markInfo;
        const userid = markInfo.fileuserid || '';
        if (name === 'Browser') {
            //const requestid  = WfForm.getReqState().getIn(['params','requestid']);
            //const userid  = WfForm.getReqState().getIn(['params','f_weaver_belongto_userid']);
            if (type === 37) {
                changedatas.signdocids = ids;
                changedatas.signdocreplacedata = list;
                submitDatas.signdocids = ids;
                this.setState(changedatas);
            } else if (type === 152) {
                changedatas.signworkflowids = ids;
                changedatas.signworkflowreplacedata = list;
                submitDatas.signworkflowids = ids;
                this.setState(changedatas);
            }
            list.map(item => {
                //unselectable='off' contenteditable='false'
                returnInfo.push(type === 37 ?
                    `<a href='/docs/docs/DocDsp.jsp?id=${item.id}&isrequest=1&requestid=${requestid}' unselectable='off' contenteditable='false'  target='_blank' title='${item.name}'   style=\"color:#2777c1;\" >${item.name}</a>&nbsp;&nbsp;`
                    :
                    `<a href='/workflow/request/ViewRequestForwardSPA.jsp?f_weaver_belongto_userid=${userid}&f_weaver_belongto_usertype=0&requestid=${item.id}&isrequest=1' unselectable='off' contenteditable='false'  target='_blank' style=\"color:#2777c1;\">${item.name}</a>&nbsp;&nbsp;`
                );
            });
        } else if (name === 'Upload') {
            if (type === 'file') {
                //先对list做处理，去重
                let newList = [];
                if(isDel){
                    newList = list;
                }else{
                    let concatList = annexdocinfos.concat(list)
                    for(const item1 of concatList){  
                        let flag = true; 
                        for(const item2 of newList){  
                            if(item1.fileid == item2.fileid){ 
                               flag = false;
                            }
                        }
                        if(flag){ 
                            newList.push(item1); 
                        }
                    }
                }
               
                let _ids = [];
                newList.map(item => { _ids.push(item.fileid) });
                changedatas['field-annexupload'] = _ids.join(',');
                changedatas['annexdocinfos'] = newList;
                if (addfileid) {
                    newList.map(item => {
                        if (item.fileid === addfileid) {
                            returnInfo.push(`<a href='javascript:void(0);' ccteim="d_${new Date().getTime()}" class="a_${item.fileid}" onclick=\"parent.openFullWindowHaveBar('/docs/docs/DocDsp.jsp?id=${item.fileid}&isrequest=1&requestid=${requestid}&desrequestid=0')\" unselectable='off' contenteditable='false' style=\"color:#2777c1;\">${item.filename}</a>&nbsp;&nbsp;`);
                        }
                    });
                } else {
                    this.setState({ 'field-annexupload': _ids, annexdocinfos: newList, visibleComponent: 'Upload', hasInitListUploadComponent: true });
                }
                submitDatas['field-annexupload'] = _ids.join(',');
            } else {
                list.map(item => {
                    const imglink = `/weaver/weaver.file.FileDownload?fileid=${item.fileidCode}`;
                    //returnInfo.push(`<img class='formImgPlay' src='${imglink}' data-imgsrc='${imglink}' onclick="window.imageCarousel(this)" alt=''/>`);
                    returnInfo.push(`<img src='${imglink}' data-imgsrc='${imglink}' alt=''/>&#8203;`);
                });
                return this.judgeIsSignature() ? " " : returnInfo.join('');
            }
        }
        //this.props.onChange && this.props.onChange(changedatas);
        this.props.changeRemarkInfo && this.props.changeRemarkInfo(submitDatas);
        this.setState(changedatas);
        if (!this.judgeIsSignature() && returnInfo.length > 0 && use_textarea_signinput != 1) {
            this.appendHtmlToCKEditor(`<p>${returnInfo.join('')}</p>`, 'last');
        } 
        return " ";
    }

    appendHtmlToCKEditor = (html, pos) =>  {
        const { markInfo = {} } = this.props;
        const { remark = "" } = this.state;
        const { use_textarea_signinput } = markInfo;
        if (use_textarea_signinput == 1) {
            this.setState({ remark: remark + html });
        } else {
            html += `<br>`;
            if (pos) {
                this.refs.WeaRichText.insertHTML(SignUtil.convertSpecialChar(html), pos);
                const el = this.refs.WeaRichText.getEditor().document.$;
                const _this = this;
                $(el).off("click").on("click", function (e) {
                    _this.setState({ visibleComponent: '' });
                });
            } else {
                this.refs.WeaRichText.insertHTML(SignUtil.convertSpecialChar(html));
            }
        }
    }

    addAtInfo = (html) =>  {
        const instances = false;// this.refs.WeaRichText.getEditor().ui.instances;
        let _html = html;
        if (instances) {
            const font = instances.Font['_'].value || getLabel(84210, '微软雅黑');
            const fontsize = instances.FontSize['_'].value || '12';
            _html = `<span style="font-family:'${font}';font-size:${fontsize}px;" >${html}</span>`;
        }
        this.appendHtmlToCKEditor(_html);
    }


//修改富文本中的数据
updateWeaRichText = (newname, id) => {
    const { markInfo = {} } = this.props;
    const { use_textarea_signinput } = markInfo;
    let val = this.refs.WeaRichText.props.value;//富文本的值
    if (use_textarea_signinput != 1)
        val = "<div>" + val + "</div>";
    let $p = $(val);
    if (!($p.length > 0)) {
        return;
    }
    if ((newname == null || newname == "") && id) {//这里主要是判断null且id存在的情况，
        $($p).find("a[class='a_" + id + "']").text("");//这个操作六六六  [注意：富文本自动正则清除空标签]
    } else {//其他情况作更改操作
        $($p).find("a[class='a_" + id + "']").text(newname);
    }


    let vals = $p[0].innerHTML;
    this.setState({ remark: vals }, () => {
        const el = this.refs.WeaRichText.getEditor().document.$;
        const _this = this;
        $(el).off("click").on("click", function (e) {
            _this.setState({ visibleComponent: '' });
        });
    });
    this.props.onChange && this.props.onChange({ remark: vals }, false);

    const { globalStore, editorId } = this.props;
    if (editorId === "remark") window.CK_REF.remark.props.isfwclear = "0";
    if (editorId !== "remark" && globalStore && window.CK_REF && window.CK_REF.remark && window.CK_REF.remark.props) {
        const { markInfo } = globalStore;
        const { value } = window.CK_REF.remark.props;
        window.CK_REF.remark.props.isfwclear = "1";
        let $remark = jQuery(value);
        $remark[0] && $remark.find("a[class='a_" + id + "']").text(newname);
        if ($remark.length > 0) {
            markInfo.remark = `${jQuery($remark)[0].innerHTML}`;
            markInfo.remarkInfo.remark = `${jQuery($remark)[0].innerHTML}`;
            window.CK_REF.remark.props.value = `${jQuery($remark)[0].innerHTML}`;
            globalStore.setMarkInfo(markInfo);//需要改变显示值
        }
    }
}

fnchangeRemarkInfo = (params) =>  {
    this.setState(params);
}
// 附件 文档  流程  位置
initButtomConfig = (bottomBarConfig) =>  {
    !!window.WfForm && WfForm.renderSignEditorBottomBar(bottomBarConfig);
    const { markInfo = {}, editorId ,  isInForm = false, globalStore,} = this.props;
    //字段是否开启拖拽， 后台是否开启拖拽，文件是否可编辑
    let { changeRemarkInfo, isdragula = true, isrename = true } = this.props;
    const { isannexupload_edit, isSignDoc_edit, isSignWorkflow_edit, phraseInfo = [], extendParams = {}, use_textarea_signinput, isSignLocation_edit = false , remarkInfo} = markInfo;
    const { visibleComponent = '', signinputPhraseDirection, signinputPhraseOffset, triangleLeft, remarkLocationInfo } = this.state;
    const { handWrittenSignSwitch } = remarkInfo;
    const f_weaver_belongto_userid  = markInfo.fileuserid || '';
    const f_weaver_belongto_usertype  = markInfo.fileloginyype == '1' ? '0' : '1';
    if (typeof changeRemarkInfo != "function") {
        changeRemarkInfo = this.fnchangeRemarkInfo;
    }
    let positionArr = [];
    let locationInfo = {};
	const {btnLabelName} =markInfo;
    if(typeof remarkLocationInfo === 'string') {
      let positionObj = getLocationInfoData(remarkLocationInfo);
      if(positionObj.longitude && positionObj.latitude&&positionObj.name) {
        positionArr = [positionObj.longitude, positionObj.latitude];
        locationInfo = {name: positionObj.name}
      }
    } else if(typeof remarkLocationInfo === 'object' && remarkLocationInfo.position && remarkLocationInfo.info){
      positionArr = remarkLocationInfo.position || [];
      locationInfo = {name: remarkLocationInfo.info.name || ''}
    }
    let params = {};//自定义参数，主要是判断是否为流程草稿
    if (true) {
        params.isFirstUploadFile = "9";//流程草稿
    }

    //手写签批
    if(handWrittenSignSwitch == 1){
        const { signHandWritten } = this.state;
        const { fileid = 0 } = signHandWritten;
       let  bottomBarRight = {
            name: 'Component',
            show: (
               <div className='handWrittenCom' onClick={(res) => { this.changeSignatureVisiable(true) }}>
                   <span className="icon-coms02-Handwritten-signature-approval" />
                        {btnLabelName.handWrittenDot}
                        {fileid > 0 && <span className="show-dot" >
                    </span>}
                </div> 
            )
        };
        bottomBarConfig.push(bottomBarRight);
    }
    
    //附件上传目录
    if (isannexupload_edit) {
        const { annexmainId, annexsubId, annexsecId, annexmaxUploadImageSize } = markInfo;
        const { hasInitListUploadComponent } = this.state;
        //未设置附件上传目录
        if (trim(annexsecId).length === 0 || annexsecId <= 0) {
        } else {
            const { annexdocinfos = [], visibleComponent = '' } = this.state;
            const category = `${annexmainId},${annexsubId},${annexsecId}`;
            if (annexdocinfos.length === 0 && !hasInitListUploadComponent) {
                bottomBarConfig.push({
                    name: 'Upload',  //上传类型组件
                    show: <div className="wea-cb-item" title={`${getLabel(385751, '附件上传(最大')}${annexmaxUploadImageSize}M/${getLabel(27591, '个')})`}>
                        <Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@16vvnh@ec1`} className="wea-cbi-icon" type="paper-clip" />
                        <span className="wea-cbi-text">{getLabel(156, '附件')}</span>
                    </div>,
                    uploadId: `${editorId}_upload`, //上传实例id
                    uploadUrl: `/api/doc/upload/uploadFile2Doc?category=${category}`, //上传地址
                    category: category,//文档目录
                    maxUploadSize: annexmaxUploadImageSize,//最大限制
                    style: { display: "inline-block", padding: 0 },
                    datas: annexdocinfos,
                    uploadParams: { ...params }
                });
            } else {
                bottomBarConfig.push({
                    name: 'Component',
                    show: <FileUpload ecId={`${this && this.props && this.props.ecId || ''}_FileUpload@tyujl3@ec2`} editorId={editorId} updateWeaRichText={this.updateWeaRichText} annexdocinfos={annexdocinfos} onChange={this.buttonBtnChange} category={category} annexmaxUploadImageSize={annexmaxUploadImageSize} visible={visibleComponent === 'Upload'} showComponent={this.showComponent}
                        changeRemarkInfo={changeRemarkInfo} isdragula={isdragula} isrename={isrename}
                    />
                });
            }
        }
    }

    if (isSignDoc_edit) {
        const { signdocreplacedata = [] } = this.state;
        bottomBarConfig.push({
            name: 'Browser',
            show: <div className="wea-cb-item" onClick={() => this.setState({ visibleComponent: '' })}>
                <span className={`wea-cbi-icon icon-coms-content-o`} style={{ 'position': 'relative' }} >
                    {signdocreplacedata.length > 0 && <div className="red-point"></div>}
                </span>
                <span className="wea-cbi-text">{getLabel(22243, '文档')}</span>
            </div>,
            type: 37,
            title: getLabel(6163, '多文档'),
            hasAdvanceSerach: true,
            idSeparator: ",",
            isAutoComplete: 0,
            isDetail: 0,
            isMultCheckbox: false,
            isSingle: false,
            linkUrl: "/docs/docs/DocDsp.jsp?isrequest=1&id=",
            pageSize: 10,
            viewAttr: 2,
            zIndex: 1050,
            replaceDatas: signdocreplacedata,
            icon: 'icon-coms-doc',
            iconBgcolor: '#df583a',
            memorise: true
        });
    }

    if (isSignWorkflow_edit) {
        const { signworkflowreplacedata = [] } = this.state;
        bottomBarConfig.push({
            name: 'Browser',
            show: <div className="wea-cb-item" onClick={() => this.setState({ visibleComponent: '' })}>
                <span className={`wea-cbi-icon icon-coms-Workflow-o`} style={{ 'position': 'relative' }} >
                    {signworkflowreplacedata.length > 0 && <div className="red-point"></div>}
                </span>
                 <span className="wea-cbi-text">{btnLabelName.signworkflow}</span>
            </div>,
            type: 152,
            hasAdvanceSerach: true,
            isDetail: 0,
            isMultCheckbox: false,
            isSingle: false,
            linkUrl: "/workflow/request/ViewRequest.jsp?isrequest=1&requestid=",
            tabs: [{
                dataParams: { "f_weaver_belongto_userid":f_weaver_belongto_userid,"f_weaver_belongto_usertype":f_weaver_belongto_usertype },
                isSearch: false,
                key: "1",
                name: getLabel(332, '全部'),
                selected: false
            },
            {
                dataParams: { collReq: "1","f_weaver_belongto_userid":f_weaver_belongto_userid,"f_weaver_belongto_usertype":f_weaver_belongto_usertype },
                isSearch: false,
                key: "2",
                name: getLabel(18030, '我的收藏'),
                selected: false
            }
            ],
            title: getLabel(33924, "多流程"),
            viewAttr: 2,
            zIndex: 1050,
            replaceDatas: signworkflowreplacedata,
            icon: 'icon-coms-workflow',
            iconBgcolor: '#0079DE',
            memorise: true
        });
    }
    //富文本底部自定义位置
    if(isSignLocation_edit) {
      bottomBarConfig.push({
        name: 'Component',
        show: <WfMapLocation ecId={`${this && this.props && this.props.ecId || ''}_WfMapLocation@kj7yag@ec3`}
              location = {positionArr}
              locationInfo = {locationInfo}
              onMapLocationChange={this.mapLocationChange}
              />
      })
    }
    
    if (use_textarea_signinput == 1 && !this.judgeIsSignature()) {
        const { belongTest } = this.state;
        bottomBarConfig.push({
            name: 'Component',
            show: <div>
                <div style={{ marginRight: "20px" }}>
                    <WfPhrase ecId={`${this && this.props && this.props.ecId || ''}_WfPhrase@8wysgv@ec4`}
                        remark={this.state.remark}
                        visiableAdd_phrase={this.props.visiableAdd_phrase}
                        setVisiableAdd_phrase={this.props.setVisiableAdd_phrase}
                        saveCallBack={this.props.saveCallBack}
                        appendHtmlToCKEditor={this.appendHtmlToCKEditor}
                        extendParams={extendParams}
                        phraseInfo={phraseInfo}
                        editorId={editorId}
                        visible={visibleComponent === 'WfPhrase'}
                        signinputPhraseDirection={editorId === "remark" ? signinputPhraseDirection : "top"}
                        signinputPhraseOffset={signinputPhraseOffset}
                        triangleLeft={triangleLeft}
                        belongTest={belongTest}
                        use_textarea_signinput={use_textarea_signinput}
                        onAddPhrase={this.doOnChangeEvent}
                        showComponent={this.showComponent} />
                </div>
                <div style={{ position: "absolute", top: "6px", right: "10px" }}>
                    <WeaHelpfulTip ecId={`${this && this.props && this.props.ecId || ''}_WeaHelpfulTip@ah4v1n@ec5`}
                        title={getLabel(513575, "当前签字意见框是textarea类型的，不支持含html格式的批示语内容显示")}
                        placement="top"
                        width={210}
                    />
                </div>
            </div>
        });
    }

}

initExtentsConfig = (extentsConfig) =>  {
    const { markInfo = {}, editorId, requestid = -1 } = this.props;
    const { phraseInfo = [], extendParams = {}, use_textarea_signinput } = markInfo;
    const { visibleComponent = '', signinputPhraseDirection, signinputPhraseOffset, triangleLeft, belongTest } = this.state;
    
    extentsConfig.push({
        name: "At",
        position: "last",
        tipTitle: getLabel(124785, "在签字意见框中输入@可直接选择节点参与人"),
        // data:this.state.operators,
        request: {
            url: "/api/workflow/forward/getReqWfNodeOperators?isDistinct=1",
            type: "GET",
            // params:{
            //     pageSize:5,
            //     pageIndex:1,
            //     name:"",
            // }
            params: {
                requestid: requestid
            }
        }
    });

    //常用批示语
    extentsConfig.push({
        name: 'Component',
        show: <WfPhrase ecId={`${this && this.props && this.props.ecId || ''}_WfPhrase@qj4ton@ec6`}
            remark={this.state.remark}
            visiableAdd_phrase={this.props.visiableAdd_phrase}
            setVisiableAdd_phrase={this.props.setVisiableAdd_phrase}
            saveCallBack={this.props.saveCallBack}
            appendHtmlToCKEditor={this.appendHtmlToCKEditor}
            extendParams={extendParams}
            phraseInfo={phraseInfo}
            editorId={editorId}
            visible={visibleComponent === 'WfPhrase'}
            signinputPhraseDirection={signinputPhraseDirection}
            signinputPhraseOffset={signinputPhraseOffset}
            triangleLeft={triangleLeft}
            belongTest={belongTest}
            use_textarea_signinput={use_textarea_signinput}
            showComponent={this.showComponent} />
    });

   
}


mapLocationChange = (locationInfo={}) => {
  let locationInfoStr = '';
  const { changeRemarkInfo } = this.props;
  let date = new Date(); 
  locationInfoStr += date.getTime() + ','; //加入时间戳
  if(locationInfo.position.length >= 2 && locationInfo.info) {
    locationInfo.position.map( v => {
      locationInfoStr += v + ',';
    })
    if(locationInfo.info.address) {
      locationInfoStr += locationInfo.info.name;
    } 
    this.setState({
      remarkLocation: locationInfoStr,
      remarkLocationInfo: locationInfo 
    })
    changeRemarkInfo && changeRemarkInfo({remarkLocation: locationInfoStr});
  } else {
    this.setState({
      remarkLocation: '',
      remarkLocationInfo: {} 
    })
    changeRemarkInfo && changeRemarkInfo({remarkLocation: ''});
  }
}

showComponent = (componet) => {
    if (componet == "WfPhrase") {
        this.setWfPhraseExtendParams()
    }
    this.setState({ visibleComponent: componet });
}

triggerLoadReady = () => {
    const { loadReady } = this.props;
    if (typeof loadReady === 'function') {
        loadReady();
    }
}

doStatusChange = (status) =>  {
    const { markInfo = {} } = this.props;
    const { use_textarea_signinput } = markInfo;
    if (status === "ready") {
        this.triggerLoadReady();
        const _this = this;
        const { editorId } = this.props;
        if (editorId === 'remark') {
            const { controlVariableMap } = this.props;
            $('#container').bind('click', function (e) {
                if ($(e.target).parents('.wea-ckeditor-fileupload,.wf-ckeditor-wfat,.wf-ckeditor-wfphrase,.wf-signature-dialog').length <= 0) {
                    _this.setState({ visibleComponent: '' });
                }
                const remark = window.CK_REF.remark && window.CK_REF.remark.getData();
                let local_target = Array.from($(e.target))[0].localName;
                let check = $(e.target).parents('#remark').length <= 0 &&
                    trim(remark).length === 0 &&
                    $(".wf-req-sign-input").find(".remark_list_dom").length <= 0 &&
                    !(local_target === "a" || local_target === "span") &&
                    $(e.target).parents(".wea-popover-hrm-wrapper").length < 1 &&
                    $(e.target).parents(".wf-signature-dialog").length < 1

                if (check) {
                    typeof this.setWfPhraseExtendParams === "function" && this.setWfPhraseExtendParams();
                    typeof controlVariableMap === 'function' && controlVariableMap('isShowSignInput', false); // 关闭编辑器
                }
            });
        }

        if ('forwardremark' === editorId) {
            $('.wf-req-forward-dialog .ant-modal-content').bind('click', function (e) {
                if ($(e.target).parents('.wea-ckeditor-fileupload,.wf-ckeditor-wfat,.wf-ckeditor-wfphrase').length <= 0) {
                    _this.setState({ visibleComponent: '' });
                }
            });
        }
        if (use_textarea_signinput != 1) {
            const editor = this.refs.WeaRichText.getEditor();
            const ckeditorid = this.refs.WeaRichText.editor.container.getId();
            let i = 0;
            const el = editor.document.$;
            let timer = setInterval(() => {
                $(el).off("click").on("click", function (e) {
                    _this.setState({ visibleComponent: '' });
                });
                i++;
                if (i > 10) {
                    clearInterval(timer);
                }
            }, 500);
            // this.initAutoAt($(`#${ckeditorid}`).find('iframe')[0]);
        }
        window.CK_REF[editorId] = this.refs.WeaRichText;
    }
}

setWfPhraseExtendParams = () => {
    const { markInfo = {}, editorId } = this.props;
    const { signinputPhraseDirection } = this.state;
    const { phraseInfo = [], } = markInfo;
    const { extendParams = {} } = markInfo;
    const { signinputPhraseWidth = 305 } = extendParams;
    if (editorId === "remark") {
        //【常用批示语】按钮离req-form-wrap底部的距离
        let WfPhraseBtn_bottomHeight = jQuery(".wf-req-form-wrapper") && jQuery(".wf-ckeditor-wfphrase") && jQuery(".wf-ckeditor-wfphrase").offset() ?
            jQuery(".wf-req-form-wrapper").height() + jQuery(".wf-req-form-wrapper").offset().top - jQuery(".wf-ckeditor-wfphrase").offset().top - jQuery(".wf-ckeditor-wfphrase").height() : 0;
        //【常用批示语高度】
        let signinputPhraseHeight = phraseInfo.length > 5 ? 5 * 30 + 90 : phraseInfo.length * 30 + 90;
        if (((signinputPhraseHeight > WfPhraseBtn_bottomHeight) && signinputPhraseDirection === "bottom")) {
            this.setState({ signinputPhraseDirection: "top" });
        }
        if ((signinputPhraseHeight <= WfPhraseBtn_bottomHeight) && signinputPhraseDirection === "top") {
            this.setState({ signinputPhraseDirection: "bottom" });
        }
        //【常用批示语】左边定位计算
        if (jQuery(".wf-ckeditor-wfphrase").length <= 0)
            return;
        let phraseBtn = editorId === "remark" ? jQuery("#remark_div .wf-ckeditor-wfphrase") : jQuery("#forwardremark .wf-ckeditor-wfphrase");
        let wfphraseBtn_width = phraseBtn.width() ? phraseBtn.width() : 1;
        let offset_left = phraseBtn.offset() && phraseBtn.offset().left ? phraseBtn.offset().left : 0;
        if ((signinputPhraseWidth / 2 >= offset_left + wfphraseBtn_width / 2)) {
            this.setState({ signinputPhraseOffset: 0, triangleLeft: wfphraseBtn_width / 2 });
        } else {
            this.setState({ signinputPhraseOffset: -117, triangleLeft: signinputPhraseWidth / 2 });
        }
    } else {
        if (jQuery(".wf-ckeditor-wfphrase").length <= 0)
            return;
        let phraseBtn = editorId === "remark" ? jQuery("#remark_div .wf-ckeditor-wfphrase") : jQuery("#forwardremark .wf-ckeditor-wfphrase");
        let wfphraseBtn_width = phraseBtn.width() ? phraseBtn.width() : 1;
        let offset_left = phraseBtn.offset() && phraseBtn.offset().left ? phraseBtn.offset().left : 0;
        // let beforePhraseWith = offset_left - jQuery("#forwardremark .wea-rich-text-toolbar-bottom").offset().left
        // if(signinputPhraseWidth/2 >= offset_left + phraseBtn.width()/2 - jQuery().offset("#forwardremark .wea-rich-text-toolbar-bottom").left){
        //     this.setState({signinputPhraseOffset: -beforePhraseWith, triangleLeft: wfphraseBtn_width/2 });
        // }else{
            this.setState({signinputPhraseOffset:-signinputPhraseWidth/2 + wfphraseBtn_width/2 , triangleLeft: signinputPhraseWidth/2 });
        // }
    }
}

initAutoAt = (ifr)  =>  {
    const { editorId } = this.props;
    const _this = this;
    const ckeditor = this.refs.WeaRichText;
    try {
        let datas = window.__atdata;
        if (window.__atdataready != true || !!!datas) {
            setTimeout(function () {
                _this.initAutoAt(ifr);
            }, 1000);
            return;
        }

        var allatids = ",";
        var names = jQuery.map(datas, function (value, i) {
            if (allatids.indexOf("," + value.uid + ",") == -1) {
                allatids += value.uid + ",";
                return { 'id': value.uid, 'name': value.data, 'py': value.datapy };
            }
        });
        var at_config = {
            at: "@",
            data: names,
            tpl: "<li data-value='@${name}'>${name}</li>",
            insert_tpl: "<a href='/hrm/HrmTab.jsp?_fromURL=HrmResource&id=${id}' atsome='@${id}' contenteditable='false' style='cursor:pointer;text-decoration:none !important;margin-right:8px;color:#2777c1!important;' target='_blank'>${atwho-data-value}</a>",
            limit: 100,
            show_the_at: true,
            start_with_space: false,
            with_repeat_matcher: false,
            search_key_py: 'py',
            ckeditor: ckeditor,
            editorId: editorId
        }
        jQuery(ifr.contentDocument.body).atwho('setIframe', ifr).atwho(at_config);
        var atwhoblockobj = jQuery(".atwho-view");
        atwhoblockobj && atwhoblockobj.perfectScrollbar({ horizrailenabled: false, zindex: 11111 });
    } catch (e) { }
}

initForwardRemarkData = (editorId, visible, initData = {}) => {
    if (("forwardremark" === editorId || "freeWorkflowSimple" === editorId) && visible) {
        if (window.REMARK_CK_REF && window.REMARK_CK_REF.refs.signInput) {
            const ckState = window.REMARK_CK_REF.refs.signInput.state;
            const { signdocids = '', signdocreplacedata = [], signworkflowids = '', signworkflowreplacedata = [], remarkLocation = '', annexdocinfos = [], signHandWritten,remarkLocationInfo } = ckState;
            const { markInfo } = this.props;
            const { extendParams = {}, use_textarea_signinput = 0, isFormSignature } = markInfo;
            if ((window.CK_REF && window.CK_REF.remark) || isFormSignature == 1) {
                const { wfSignDefaultFontFamily = '', wfSignDefaultFontSize = '' } = extendParams;
                let remarkTemp = "";
                if(isFormSignature == 1){//签章
                    if(typeof window.saveAutographMul === "object"){
                        if(window.saveAutographMul && window.saveAutographMul.wfWeaAutographCompremark){
                            const requestlog = window.saveAutographMul.wfWeaAutographCompremark(false,true)
                            const { workflowRequestLogId = '' } = initData;
                            initData.workflowRequestLogId = workflowRequestLogId != -1 ? workflowRequestLogId : requestlog.recordId;
                        }
                    }
                }else {
                    remarkTemp = window.CK_REF.remark && window.CK_REF.remark.getData();
                    if (use_textarea_signinput == 0) {
                        remarkTemp = SignUtil.appendDefaultSytle(remarkTemp, wfSignDefaultFontFamily, wfSignDefaultFontSize);
                    }
                    const { remark = '' } = initData;
                    if(trim(remarkTemp).length > 0){
                        initData.remark = remark || remarkTemp;
                    }
                }
                if (trim(remarkTemp).length > 0 || signdocreplacedata.length > 0 || signworkflowreplacedata.length > 0 || annexdocinfos.length > 0 || trim(remarkLocation).length > 0 || signHandWritten.fileid > 0||signHandWritten.fileid == undefined) {
                    initData.signdocids = signdocids;
                    initData.signdocreplacedata = signdocreplacedata;
                    initData.signHandWritten = signHandWritten;
                    initData.signhandwrittenid = signHandWritten.fileid || 0;
                    initData.signworkflowids = signworkflowids;
                    initData.signworkflowreplacedata = signworkflowreplacedata;
                    initData.remarkLocation = remarkLocation;
                    initData.remarkLocationInfo = remarkLocationInfo;
                    initData.annexdocinfos = annexdocinfos;
                }
            }
        }
    }
    if("updateEdit" == editorId && window["REMARK_CK_REF"+editorId] && window["REMARK_CK_REF"+editorId].props) {
        const {props} = window["REMARK_CK_REF"+editorId];
        let {
            signdocids = '', signdocreplacedata = [], signworkflowids = '', signworkflowreplacedata = [],
            remarkLocation = '', annexdocinfos = [], signHandWritten={}, remarkLocationInfo,remark=""
        } = props;
        const {fileid} = signHandWritten;

        if (trim(remark).length > 0 ||
            signdocreplacedata.length > 0 ||
            signworkflowreplacedata.length > 0 ||
            annexdocinfos.length > 0 ||
            trim(remarkLocation).length > 0 ||
            fileid > 0 ||
            fileid == undefined) {

            initData.remark = remark;
            initData.signdocids = signdocids;
            initData.signdocreplacedata = signdocreplacedata;
            initData.signHandWritten = signHandWritten;
            initData.signhandwrittenid = fileid;
            initData.signworkflowids = signworkflowids;
            initData.signworkflowreplacedata = signworkflowreplacedata;
            initData.remarkLocation = remarkLocation;
            initData.remarkLocationInfo = remarkLocationInfo;
            initData.annexdocinfos = annexdocinfos;
        }
    }
    return initData;
}

//获取@人员信息
getAtOperators = () => {
    const { requestid = -1 } = this.props;
    WeaTools.callApi('/api/workflow/forward/getReqWfNodeOperators', 'get', { requestid: requestid }).then(res => {
        const { operators = [] } = res;
        this.setState({ operators })
    });
}

//解決切换源码时@功能失效
setMode = (mode)  => {
    if (mode === 'source') {
        const { editorId } = this.props;
        window.ATWHO_APP[editorId].shutdown();
        window.ATWHO_APP[editorId].$inputor.data('atwho', null);
    }
    if (mode === 'wysiwyg') {
        const ckeditorid = this.refs.WeaRichText.editor.container.getId();
        // this.initAutoAt($(`#${ckeditorid}`).find('iframe')[0]);
    }
}
}
